<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="iwpl.project.entities.Employees"%>
<%@page import="iwpl.project.entities.Contracts"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@page import="iwpl.project.dao.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'Insert_BuyingContract.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
		<script type="text/javascript" src="js/datepicker.js"></script>
<script src="js/jquery-Source.js"></script>
		<script type="text/javascript"
			src="js/jquery-Validation.js"></script>
		<script type="text/javascript">
  $(document).ready(function()
  {
    $("#commentForm").validate();
  });
  </script>
  <script type="text/javascript">
  	function updatebuying(control)
  	{
  		//location.href("/DepartmentManage/servlet/Control_Contract?action=updatebuying")
  		var frm = document.getElementById("frm");
  		frm.action = "/DepartmentManage/servlet/Control_Contract?action=updatebuying&ctrid="+control;
  		frm.method = "post";
  		frm.submit();
  	}
  </script>
  <script type="text/javascript">
  	function loadcontrol()
  	{
  		var txtcontracttype = document.getElementById("txtcontracttype");
  		txtcontracttype.disabled=true;
  	}
  </script>
  </head>
  
  <body onload="loadcontrol()">
  <%
  	Integer empid1=0;
  	Date sign=null;
  	Date pur=null;
  	Date redate=null;
  	String sid=request.getParameter("ctrid");
  	ContractsDAO dao1=new ContractsDAO();
  	Contracts data1=dao1.findById(Integer.parseInt(sid));
  	empid1=data1.getEmployees().getId();
  	sign=data1.getSigningDate()	;
  	pur=data1.getPurchaseDate();
  	redate=data1.getReceivedOfDate();
   %>
  <form method="post" id="frm">
     			<table align="center" border="1px" cellpadding="0" cellspacing="0"
				style="width: 780px; border-color: #3399FF">
				<tr>
					<td colspan="2"><jsp:include page="Header.jsp"></jsp:include>
					</td>
				</tr>
				<tr>
					<td style="width: 245px" nowrap="nowrap" valign="top">&nbsp;<jsp:include page="Left.jsp"></jsp:include>
					</td>
					<td style="width: 75%" valign="top">

			
   					 <hr width="100%"/>
    
   						<table>
   							<tr>
   								
   								<td>
   									<input type="hidden" name="hdid" value=<%=sid %>>
   								</td>
   								
   							</tr>
   							<tr>
   								<td><b>Employee : </b></td>
   								<td>
   									<select name="cboemp" value=<%=empid1 %>>
   									<%
   										EmployeesDAO dao=new EmployeesDAO();
   										Employees emp=new Employees();
   										List data=dao.findAll();
   										Iterator ir=data.listIterator() ;
   										
   										while(ir.hasNext())
   										{
   											emp=(Employees)ir.next();
   											int empid=emp.getId();
   											String empname=emp.getFullName();
   											out.print("<option value="+empid+">"+empname+"</option>");
   										}
   										//out.print("</select>");
   									 %>
   									 </select>
   								</td>
   								<td><a href=#>Find</a></td>
   							</tr>
   							<tr>
   								<td><b>Apartment : </b></td>
   								<td>
   									<label name="lblapartment"></label>
   									<input name="hdapartment" type="hidden"> 
   								</td>
   								<td><a href=#>Find</a></td>
   							</tr>
   							<tr>
   								<td><b>SigningDate : </b></td>
   								<td>
   									<input type="text" name="txtsigningdate" value=<%=sign %>/>
   								</td>
   								<td>
   									<input type="button" name="bntsdate" value="Select Date" onclick="displayDatePicker('txtsigningdate', this);">
   								</td>
   							</tr>
   							<tr>
   								<td><b>PurchaseDate : </b></td>
   								<td>
   									<input type="text" name="txtpurchasedate" value=<%=pur %>/>
   								</td>
   								<td>
   									<input type="button" name="bntpdate" value="Select Date" onclick="displayDatePicker('txtpurchasedate', this);">
   								</td>
   							</tr>
   							<tr>
   								<td><b>ReceiveDate : </b></td>
   								<td>
   									<input type="text" name="txtreceivedate" value=<%=redate %>/>
   								</td>
   								<td>
   									<input type="button" name="bntrdate" value="Select Date" onclick="displayDatePicker('txtreceivedate', this);">
   								</td>
   							</tr>
   							<tr>
   								<td colspan="3">
   									<center>
   										<table>
   											<tr>
   												<td>
   													<input type="button" name="bntupdate" value="Update" onclick="updatebuying(hdid.value);">
   												</td>
   												<td>
   													<input type="button" name="bntcancel" value="Cancel">
   												</td>
   											</tr>
   										</table>
   									</center>
   								</td>
   							</tr>
   						</table>

					</td>
				</tr>
			</table>
			</form>
  </body>
</html>
